package org.cc.cloud.controller;

import org.cc.cloud.ProviderClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.netflix.hystrix.HystrixCircuitBreaker;
import com.netflix.hystrix.HystrixCommandKey;

@Controller
public class FeignController {
	@Autowired
	private ProviderClient providerClient;
	@GetMapping("/feignCall")
	@ResponseBody
	public String call(){
		String result=providerClient.call(1);
		return result;
		
	}

	@GetMapping("/hello")
	@ResponseBody
	public String hello(){
		
		String result=providerClient.hello("cc");
		return result;
		
	}
	@GetMapping("/hellown")
	@ResponseBody
	public String hellown(){
		String result=providerClient.hellown();
		return result;
	}
	@RequestMapping(method = RequestMethod.GET, value = "/toHello")
	public String toHello() {
		String result = providerClient.toHello();
		HystrixCircuitBreaker breaker = HystrixCircuitBreaker.Factory
				.getInstance(HystrixCommandKey.Factory
						.asKey("ProviderClient#toHello()"));	
		return result;
	}
}
